Usually the upgrade process for various web based software is very simple. Enter a few commands over SSH, run a script or even upgrade via an admin control panel. Upgrading the Ghost blogging platform is very similar.
In this post I will run you through a very quick way of upgrading Ghost to the latest version.
How to Upgrade a Ghost Blog
Before you upgrade any software it is always recommended to backup all your data. Luckily Ghost has a simple way of backing up.
Log into your blog admin control panel and then go to Settings > Labs. Now click the export button. This will download a .JSON file. This file can be used to restore your blog.
It is also recommended that you backup your images and theme in your \ghost\content\ directory. This can be done by logging into your server via FTP, SFTP or any other method of accessing your server for file transfers.
SSH into your server
CD \to\ghost\installation\folder
wget http://allaboutghost.com/updateghost
chmod +x updateghost
./updateghost
The script will run and once it has finished you can now run ghost with your preferred method. At BitBangers we like to run our Ghost blog with Forever. So to get our blog up and running again we need to enter the following command.
NODE_ENV=production forever start index.js
If the script has run correctly you should have a fully update Ghost instance running.
Below is the contents of the updateghost script.
#!/bin/bash
# Written by Andy Boutte and David Balderston of howtoinstallghost.com, ghostforbeginners.com and allaboutghost.com
# updateghost.sh will update your current ghost install to the latest version without you losing any content
if [ -f config.js ]
then
echo `whoami`
# Make temporary directory and download latest Ghost.
mkdir temp
cd temp
curl -L -O https://ghost.org/zip/ghost-latest.zip
unzip *.zip
cd ..
# Make database backups.
for file in content/data/*.db;
do cp "$file" "${file}-backup-`date +%Y%m%d`";
done
# Copy the new files over.
yes | cp temp/*.md temp/*.js temp/*.json .
rm -R core
yes | cp -R temp/core .
yes | cp -R temp/content/themes/casper content/themes
npm install --production
# Delete temp folder.
rm -R temp
echo "You can now start Ghost with npm, forever or whatever else you use."
else
echo "Please cd to your Ghost directory."
fi
Thanks to HowToInstallGhost for proving the script and instructions.